package com.matrix.java.chap_06;

import java.util.Scanner;

/*
    检测密码
 */
public class Ex6_18 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("输入密码: ");
        String password = input.next();
        input.close();
        System.out.println(passwordCheck(password));
    }

    private static String passwordCheck(String password) {
        int countNum = 0;
        if (password.length() < 8) {
            return "Invalid Password 1";
        }
        for (int i = 0; i < password.length(); i++) {
            char ch = password.charAt(i);
            if (ch > 48 && ch < 58) {
                countNum++;
            } else if ((ch > 64 && ch < 91) || (ch > 96 && ch < 123)) {
            } else {
                return "Invalid Password 2";
            }
        }
        if (countNum < 2) {
            return "Invalid Password 3";
        }
        return "Valid Password";
    }
}

